package com.ssm.zhihu_ssm.controller;


import com.ssm.zhihu_ssm.entity.QuestionAnswerList;
import com.ssm.zhihu_ssm.entity.User;

import com.ssm.zhihu_ssm.service.FollowService;
import com.ssm.zhihu_ssm.service.UserService;
import com.ssm.zhihu_ssm.util.ReturnMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Max;
import java.util.List;
import java.util.Map;

@RestController
public class FollowController {

    @Autowired
    private FollowService followService;
    @Autowired
    private UserService userService;


    @RequestMapping("/findFollow")//该用户关注的所有人
    @ResponseBody
    private Map<String, Object> findFollow(String phone) {
        int x = userService.findId(phone);
        List<User> userFollow = followService.findUserFollow(x);
        Map<String, Object> map = ReturnMap.ReturnMapS(userFollow);
        return map;

    }

    @RequestMapping("/befindFollow")//该被那些人关注
    @ResponseBody
    private Map<String, Object> AttentionFollow(String phone) {

        int x = userService.findId(phone);
        System.out.println(x);
        List<User> userFollow = followService.AttentionUserFOLLOWED(x);
        System.out.println(userFollow);
        Map<String, Object> map = ReturnMap.ReturnMapS(userFollow);
        return map;

    }

    @RequestMapping("/findFollowQuestion")//关注的文章
    @ResponseBody
    private Map<String, Object> findFollowQuestion(String phone) {

        int x = userService.findId(phone);
        System.out.println(x);
        List<QuestionAnswerList> lists = followService.findFollowQuestion(x);
        Map<String, Object> map = ReturnMap.ReturnMapS(lists);
        return map;

    }
}
